package net.lainiao.morethread.Chapter5.demo2;

import java.util.Random;

/**
 * Created by Administrator on 2017/3/6.
 */
public class DocumentMock {
    private String words[]={"the","hello","goodbye","packt","java","thread","pool","random","class","main"};
    public String[][]generateDocument(int numLines,int numWords,String word){
        int counter=0;
        String document[][]=new String[numLines][numWords];
        Random random=new Random();
        int wordLength=words.length;
        for (int i = 0; i < numLines; i++) {
            for (int j = 0; j < numWords; j++) {
                int index=random.nextInt(wordLength);
                document[i][j]=words[index];
                if(document[i][j].equals(word)){
                    counter++;
                }
            }
            
        }
        System.out.println("DocumentMock: The word apperars "+counter+" times in the document");
        return document;
    }



}
